//
//  HMSignUpStrongCourseCell.m
//  HMSignUpStrongCourse
//
//  Created by 陈辉明 on 2017/11/25.
//  Copyright © 2017年 goldwin. All rights reserved.
//

#import "HMSignUpStrongCourseCell.h"
#import "HMSignUpStrongCourseModel.h"
@interface HMSignUpStrongCourseCell()
@property (weak, nonatomic) IBOutlet UIView *cellView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *cellViewTop;


@end

@implementation HMSignUpStrongCourseCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}



-(void)setModel:(HMSignUpStrongCourseModel *)model {
    _model = model;
    self.cellViewTop.constant = model.setCourseComments.count *29 +20;
    [self.cellView setNeedsLayout];
  
    
    if (self.isCreat) {
        return;
    }
    
    for (int i = 0; i < model.setCourseComments.count; i++) {
        UIView *view = [UIView new];
        CGFloat Y = i *29 + 10;
        view.frame = CGRectMake(0, Y,[UIScreen mainScreen].bounds.size.width, 29);
        [self.contentView addSubview:view];
        UIImageView *picImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_yaosu"]];
        picImage.frame= CGRectMake(15, 7, 15, 15);
        UILabel *nameLabel = [UILabel new];
        nameLabel.textAlignment = NSTextAlignmentLeft;
        nameLabel.font = [UIFont systemFontOfSize:17];
        nameLabel.textColor = [UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1];
        nameLabel.frame = CGRectMake(45, 4, 150, 21);
        nameLabel.text = model.setCourseComments[i].content;
        [view addSubview:nameLabel];
        [view addSubview:picImage];
    }
    //查看详情按钮
    UIButton *seeMore = [UIButton buttonWithType:(UIButtonTypeCustom)];
    seeMore.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 15 - 78 - 15, (model.setCourseComments.count *29-25 + 20) /2, 78, 25);
    [seeMore setBackgroundImage:[UIImage imageNamed:@"btn_chakan"] forState:(UIControlStateNormal)];
    
    [seeMore setTitle:@"查看详情" forState:(UIControlStateNormal)];
    [seeMore setTitleColor:[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1] forState:UIControlStateNormal];
    seeMore.titleLabel.font = [UIFont systemFontOfSize:16];
    
    [seeMore addTarget:self action:@selector(clickSeeMoreButton) forControlEvents:(UIControlEventTouchUpInside)];
    
    [self.contentView addSubview:seeMore];
    
    
    self.isCreat = YES;
    
}



- (void)clickSeeMoreButton {
    if (self.seeMoreBlock) {
        self.seeMoreBlock(self.model);
    }
}


@end
